package org.abox.tools.ant.taskdefs.mks.si;

import org.abox.tools.ant.taskdefs.mks.common.BaseTask;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.tools.ant.BuildException;

import com.mks.api.Command;
import com.mks.api.response.APIException;
import com.mks.api.response.Response;

public class SITask extends BaseTask {
	private static final Log LOG = LogFactory.getLog(SITask.class);

	private String command;

	public void setCommand(String command) {
		this.command = command;
	}

	public String getCommand() {
		return command;
	}

	@Override
	public void execute() throws BuildException {
		Command ping = new Command("si", command);

	    // Execute the command
		Response res;
		try {
			res = runCommand(ping);
			LOG.info(res.getCommandString() + " returned exit code " + res.getExitCode());
		} catch (APIException e) {
			throw new BuildException("API ping faulre: ", e);
		}
	}

}
